package button

import (
	"yunj/pkg/yunj/core/builder/form"
)

// 提交
type Submit struct {
	form.Button
}

func NewSubmit() *Submit {
	b := &Submit{}
	form.SetButtonInstance(&b.Button, b)
	return b
}

// 设置描述文字
func (b *Submit) SetText(text string) *Submit {
	b.Text = text
	return b
}

// 设置class
func (b *Submit) SetClass(class string) *Submit {
	b.Class = class
	return b
}

// 设置图标class
func (b *Submit) SetIcon(icon string) *Submit {
	b.Icon = icon
	return b
}

// 设置权限
func (b *Submit) SetAuth(auth string) *Submit {
	b.Auth = auth
	return b
}

// 处理按钮属性
func (b *Submit) HandleAttr() error {
	if b.Text == "" {
		b.Text = "提交"
	}
	if b.Icon == "" {
		b.Icon = "yunj-icon-submit"
	}
	return nil
}
